# for 循环九九乘法表
#1
for row in range(1,10):
    for col in range(1,row+1):
        print('{}*{}={:<4}'.format(row,col, row*col), end=' ')
    print('')
print('')
print('='*100)

#2
for row in range(9,0,-1):
    for col in range(1,row+1):
        print('{}*{}={:<4}'.format(row,col, row*col), end=' ')
    print('')
print('')
print('='*100)

#3
for row in range(1,10):
    for col in range(9,0,-1):
        if row < col:
            print(' ' * 8, end = '')
        else:
            print('{}*{}={:<4}'.format(row, col, row * col), end='')
    print('')
print('='*100)

#4
for row in range(9,0,-1):
    for col in range(9,0,-1):
        if row < col:
            print(' '*8, end='')
        else:
            print('{}*{}={:<4}'.format(row, col, row * col), end='')
    print('')
print('='*100)

# while 循环九九乘法表
# 1
row = 1
while row <=9:
    col = 1
    while col <= row:
        print('{}*{}={:<4}'.format(row,col, row*col), end='')
        col +=1
    row += 1
    print('')
print('')
print('='*100)

#2
row = 9
while row >=1:
    col = 1
    while col <= row:
        print('{}*{}={:<4}'.format(row,col, row*col), end='')
        col +=1
    row -= 1
    print('')
print('='* 100)

#3
row = 1
while row <= 9:
    col = 9
    while col >= 1:
        if row < col:
            print(' '*8, end='')
        else:
            print('{}*{}={:<4}'.format(row, col, row * col), end='')
        col -= 1
    row += 1
    print('')
print('='*100 )

#4
row = 9
while row>=1:
    col = 9
    while col >= 1:
        if row < col:
            print(' '*8, end='')
        else:
            print('{}*{}={:<4}'.format(row, col, row * col), end='')
        col -= 1
    row -= 1
    print('')
print('='*100)